/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kungkhies.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author clayton
 */
@Entity 
@Table(name = "assessment")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Assessment.findAll", query = "SELECT a FROM Assessment a"),
    @NamedQuery(name = "Assessment.findByAssessmentId", query = "SELECT a FROM Assessment a WHERE a.assessmentId = :assessmentId"),
    @NamedQuery(name = "Assessment.findByDisplayName", query = "SELECT a FROM Assessment a WHERE a.displayName = :displayName"),
    @NamedQuery(name = "Assessment.findByTimeEstimate", query = "SELECT a FROM Assessment a WHERE a.timeEstimate = :timeEstimate")
})
public class Assessment implements Serializable 
{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "assessment_id")
    private Long assessmentId;
    @Size(max = 256)
    @Column(name = "display_name")
    private String displayName;
    @Lob
    @Size(max = 65535)
    @Column(name = "description")
    private String description;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "time_estimate")
    private Float timeEstimate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "assessment")
    private Collection<ActivityAssessment> activityAssessmentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "assessmentId")
    private Collection<AssessmentUrl> assessmentUrlCollection;

    public Assessment()
    {
    }

    public Assessment(Long assessmentId)
    {
        this.assessmentId = assessmentId;
    }

    public Long getAssessmentId()
    {
        return assessmentId;
    }

    public void setAssessmentId(Long assessmentId)
    {
        this.assessmentId = assessmentId;
    }

    public String getDisplayName()
    {
        return displayName;
    }

    public void setDisplayName(String displayName)
    {
        this.displayName = displayName;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public Float getTimeEstimate()
    {
        return timeEstimate;
    }

    public void setTimeEstimate(Float timeEstimate)
    {
        this.timeEstimate = timeEstimate;
    }

    @XmlTransient
    public Collection<ActivityAssessment> getActivityAssessmentCollection()
    {
        return activityAssessmentCollection;
    }

    public void setActivityAssessmentCollection(Collection<ActivityAssessment> activityAssessmentCollection)
    {
        this.activityAssessmentCollection = activityAssessmentCollection;
    }

    @XmlTransient
    public Collection<AssessmentUrl> getAssessmentUrlCollection()
    {
        return assessmentUrlCollection;
    }

    public void setAssessmentUrlCollection(Collection<AssessmentUrl> assessmentUrlCollection)
    {
        this.assessmentUrlCollection = assessmentUrlCollection;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (assessmentId != null ? assessmentId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Assessment))
        {
            return false;
        }
        Assessment other = (Assessment) object;
        if ((this.assessmentId == null && other.assessmentId != null) || (this.assessmentId != null && !this.assessmentId.equals(other.assessmentId)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "com.kungkhies.persistence.entities.Assessment[ assessmentId=" + assessmentId + " ]";
    }

}
